package com.ayoka.parenting.ui.launch;

import com.ayoka.parenting.bean.BaseResponse;
import com.ayoka.parenting.bean.UserManager;
import com.ayoka.parenting.http.API;
import com.ayoka.parenting.http.HttpBeanInterceptCallback;
import com.ayoka.parenting.interf.CallbackUtil;
import com.ayoka.parenting.interf.RequestCallback;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: LaunchModel&.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class LaunchModel implements LaunchContract.Model{

    @Override
    public void refreshToken(LaunchPresenter launchPresenter, String userId, String refreshToken, final RequestCallback<UserManager.TokenBean> callback) {
        API.refreshToken(launchPresenter, userId, refreshToken, new HttpBeanInterceptCallback<BaseResponse<UserManager.TokenBean>>() {
            @Override
            public void onSuccess(BaseResponse<UserManager.TokenBean> response) {
                CallbackUtil.notifySuccess(callback, response.data);
            }

            @Override
            public void onFailure(int errorCode, String errorMessage) {
                CallbackUtil.notifyFailure(callback, errorCode, errorMessage);
            }
        });
    }
}
